﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Windows.Forms;
using JustMoveIt.Logic;

namespace JustMoveIt
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main(string[] args)
        {
            try
            {
                //FORCE IT
                JustMoveItLogic.Init(Application.StartupPath);
                foreach (string arg in args)
                {
                    Logger.Instance.Write(arg);
                }

                if (args.Length >= 2)
                {

                    if (args[0] == "-JMI")
                    {
                        if (Directory.Exists(args[1]))
                        {
                            JustMoveItLogic.Instance.JustMoveIt(new DirectoryInfo(args[1]));
                        }
                        else if (File.Exists(args[1]))
                        {
                            JustMoveItLogic.Instance.JustMoveIt(new FileInfo(args[1]));
                        }
                        else
                        {
                            Logger.Instance.Write("File or Folder not found : " + args[1]);
                        }

                    }
                    else
                    {
                        Logger.Instance.Write("Unknown Command \n" + "\t" + args);
                    }
                }
                else
                {

                    Application.EnableVisualStyles();
                    Application.SetCompatibleTextRenderingDefault(false);

                    Application.Run(new MainForm());
                }

            }
            catch (Exception e)
            {
                MessageBox.Show("Uncaught exception. See Debug.log for more information");
                Logger.Instance.Write(e);
            }
        }
    }
}
